package org.thread.test03;

import java.util.concurrent.Callable;

/**
 * @author ZJL
 * @date 2025-03-10
 */
public class SumThread implements Callable<Long> {
    private long sum;
    private int num1;
    private int num2;

    public SumThread(){

    }
    public SumThread(int num1, int num2) {
        this.num1 = num1;
        this.num2 = num2;
    }

    private void sum(){
        for (int i = this.num1; i <=this.num2; i++) {
            this.sum += i;
        }
    }

    @Override
    public Long call() throws Exception {
        sum();
        return this.sum;
    }
}
